import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lottie/lottie.dart';

/// 通用loading
class NttLoadingDialog extends StatelessWidget {
  /// 描述文本
  final String message;

  /// lottie动画路径
  final String lottiePath;

  /// 宽
  final double? width;

  /// 高
  final double? height;

  const NttLoadingDialog({
    super.key,
    this.message = "加载中...",
    this.lottiePath = "packages/lib_common/assets/loading.json",
    this.width,
    this.height,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Lottie.asset(
              lottiePath,
              width: width ?? 200.w, // 设置动画宽度
              height: height ?? 145.h, // 设置动画高度
              repeat: true, // 设置动画是否循环播放
            ),
            Text(
              message,
              style: TextStyle(
                fontSize: 28.r,
                color: Colors.white,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
